package com.cqut.forum.entity;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author yangxun
 * Messages entity
 * 留言表
 */
@Entity
@Table(name = "messages", catalog = "forum")
public class Messages implements java.io.Serializable {

	// Fields
	//
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer messagesId;
	private User user;
	private Integer aboveMessagesId;
	private Date messagesTime;
	private Date lastReplyTime;
	private String messagesContents;
	private String messagesState = "未读";
	private Integer acceptUserId;
	// Constructors

	/** default constructor */
	public Messages() {
	}

	/** full constructor */
	public Messages(User user, Integer aboveMessagesId, Date messagesTime,Date lastReplyTime,
			String messagesContents, String messagesState, Integer acceptUserId) {
		this.user = user;
		this.aboveMessagesId = aboveMessagesId;
		this.messagesTime = messagesTime;
		this.lastReplyTime = lastReplyTime;
		this.messagesContents = messagesContents;
		this.messagesState = messagesState;
		this.acceptUserId = acceptUserId;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "messages_id", unique = true, nullable = false)
	public Integer getMessagesId() {
		return this.messagesId;
	}

	public void setMessagesId(Integer messagesId) {
		this.messagesId = messagesId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "leave_user_id")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "above_messages_id")
	public Integer getAboveMessagesId() {
		return this.aboveMessagesId;
	}

	public void setAboveMessagesId(Integer aboveMessagesId) {
		this.aboveMessagesId = aboveMessagesId;
	}

	@Column(name = "messages_time", length = 10)
	public Date getMessagesTime() {
		return this.messagesTime;
	}

	public void setMessagesTime(Date messagesTime) {
		this.messagesTime = messagesTime;
	}

	@Column(name = "last_reply_time", length = 10)
	public Date getLastReplyTime() {
		return lastReplyTime;
	}

	public void setLastReplyTime(Date lastReplyTime) {
		this.lastReplyTime = lastReplyTime;
	}

	@Column(name = "messages_contents", length = 500)
	public String getMessagesContents() {
		return this.messagesContents;
	}

	public void setMessagesContents(String messagesContents) {
		this.messagesContents = messagesContents;
	}

	@Column(name = "messages_state", length = 6)
	public String getMessagesState() {
		return this.messagesState;
	}

	public void setMessagesState(String messagesState) {
		this.messagesState = messagesState;
	}
	@Column(name = "accept_user_id")
	public Integer getAcceptUserId() {
		return acceptUserId;
	}

	public void setAcceptUserId(Integer acceptUserId) {
		this.acceptUserId = acceptUserId;
	}
}